package xyz.fcidd.monitor.session;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

public class MybatisSession {
    /**
     * 获取数据库的session，以便后期对数据库的操作
     *
     * @return 数据库的session
     */
    public static SqlSession getSqlSession(){
        InputStream input = MybatisSession.class.getClassLoader().getResourceAsStream("config/mybatis_config.xml");
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(input);
        return sessionFactory.openSession();
    }

}
